/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

/**
 *
 * @author EricSamp
 */
public class TelaSplash extends JFrame implements Runnable{


	private static final long serialVersionUID = 1L;

	JProgressBar barra;

	public TelaSplash() {
		carregarComponentes();
	}

	private void carregarComponentes() {
		ImageIcon imagem = new ImageIcon("imagens/logo1.jpeg");
		JLabel label = new JLabel(imagem);

		JPanel painelFilhoSuperior = new JPanel();
		painelFilhoSuperior.setBackground(Color.GRAY);
		painelFilhoSuperior.add(new JLabel("Sistema para Telemarketing - Administrador"));

		barra = new JProgressBar(0, 100);
		barra.setForeground(Color.GREEN);

		JPanel painel = new JPanel();
		painel.setBackground(Color.WHITE);
		painel.setLayout(new BorderLayout());
		painel.add(painelFilhoSuperior, BorderLayout.NORTH);
		painel.add(label, BorderLayout.CENTER);
		painel.add(barra, BorderLayout.SOUTH);

		this.add(painel);
		this.setSize(400, 400);
		this.setLocationRelativeTo(null);// centraliza a tela
		this.setUndecorated(true);
		setVisible(true);
	}
	@Override
	public void run() {
		int valorLido = 0;
		while (valorLido <= 100) {
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
//	TODO			exibir algum mensagem de erro 		 
			}
			barra.setValue(valorLido++);
		}
		dispose();
	}
}
    

